% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ejscreenapi_plus.R
\name{ejscreenapi_plus}
\alias{ejscreenapi_plus}
\title{Given a set of points (lat lon), get table of EJScreen API results near each}
\usage{
ejscreenapi_plus(
  x,
  y = NULL,
  radius = 3,
  unit = "miles",
  wkid = 4326,
  fips = NULL,
  shapefile = NULL,
  namestr = "",
  report_every_n = 100,
  save_when_report = FALSE,
  format_report_or_json = "pjson",
  on_server_so_dont_save_files = FALSE,
  ipurl = "ejscreen.epa.gov",
  mapping_for_names = NULL,
  usewhichnames = "r",
  calculate_ratios = TRUE,
  verbose = FALSE,
  getstatefromplacename = TRUE
)
}
\arguments{
\item{x}{longitudes; or path/filename to xlsx or csv with lat, lon;
or data.frame or data.table with lat,lon}

\item{y}{latitudes, or ignored if x was a file or table with lat,lon info.}

\item{radius}{circular buffer radius (in miles by default, unless unit changed)}

\item{unit}{default is miles}

\item{wkid}{do not use. https://epsg.io/4326}

\item{fips}{if used instead of lon,lat it should be a character FIPS code vector
(counties, tracts, or blockgroups)}

\item{shapefile}{not implemented}

\item{namestr}{optional text}

\item{report_every_n}{default is to provide an update every so often}

\item{save_when_report}{default is FALSE but if TRUE it saves work in progress every so often}

\item{format_report_or_json}{do not use}

\item{on_server_so_dont_save_files}{default is FALSE, but set to TRUE if this is run on a server}

\item{ipurl}{change only if different URL has to be used for the EJScreen API}

\item{mapping_for_names}{a table that translates between original (as on FTP site),
short friendly (useful in coding or analysis),
and long complete variable names (for clearer Excel headers).
This can be read from a csv file or from data in a package.
Not documented here, as format may change.}

\item{usewhichnames}{default is to use the short friendly ones?}

\item{calculate_ratios}{whether to add columns with ratio of raw score to the US or State average}

\item{verbose}{whether to print to console / viewer / plot}

\item{getstatefromplacename}{set to FALSE if you need the exact output of API and
TRUE if you want to try to extract ST abbrev and statename from the placename field,
which is more likely to be correct than the stateAbbr and stateName fields in the API output.}
}
\value{
Returns a data.frame of results, one row per buffer (site), one column per indicator,
with over 300 columns.
\code{\link[=ejscreenit]{ejscreenit()}} returns that as one element of a list that also has a map and plot.
}
\description{
Using EJScreen API without Shiny app interface
}
\details{
See \code{\link[=ejscreenit]{ejscreenit()}} for more details on this.
\code{\link[=ejscreenit]{ejscreenit()}} uses functions below, but returns a list with table, map, plot, etc.
\code{\link[=ejscreenapi_plus]{ejscreenapi_plus()}} accepts file or table or vectors of point data,
uses \code{\link[=ejscreenapi]{ejscreenapi()}} to get EJScreen stats,
and then prepends input table and renames columns, to return a table.
\code{\link[=ejscreenapi]{ejscreenapi()}}    gets EJ stats for many points as a data.table of many rows.
\code{\link[=ejscreenapi1]{ejscreenapi1()}} gets EJ stats for 1 point via API, as data.frame of 1 row.
\code{\link[=ejscreenRESTbroker]{ejscreenRESTbroker()}} gets EJ stats for one point as JSON.

It also now drops redundant columns where the same numbers had been returned from API
using the normal name and a synonym name, as with TOTALPOP and "totalPop"
}
\examples{
\dontrun{ # see [ejscreenit()] for examples
  pts <- data.frame(
   siteid = 1:2,
   sitename = c("site A", "site B"),
   lon =      c(-91.132107, -91.09),
   lat =      c(30.494982,   30.45)
  )
  # pts <- testpoints_5
  
  myradius <- 1
  
  x <- testoutput_ejscreenapi_plus_5; names(x) <- fixcolnames(names(x), "r", "long")
  # x <- ejscreenapi_plus(pts,              radius = myradius, usewhichnames = "long")
  # x <- ejscreenapi_plus(x = pts$lon, y = pts$lat, radius = myradius, usewhichnames = "long")
  # x <- ejscreenapi_plus(pts,              radius = myradius, usewhichnames = "long")
  
  ## view results
  t(x[1, 3:ncol(x)])
  DT::datatable(x , escape = FALSE)
  
  names(x) <- fixcolnames(names(x), "long", "r")
  boxplots_ratios((calc_ratios_to_avg(x))$ratios_d, wheretext = myradius)
  
 }
 
}
\seealso{
\code{\link[=ejscreenit]{ejscreenit()}} which also demonstrates a map and a plot,
and accepts filename as input pts. see \code{\link[=ejscreenapi]{ejscreenapi()}} that
uses \code{\link[=ejscreenapi1]{ejscreenapi1()}} and \code{\link[=ejscreenRESTbroker]{ejscreenRESTbroker()}}
}
\keyword{internal}
